<!--页面主要内容-->
<main class="lyear-layout-content">
  <div class="container-fluid p-t-15">
    <div class="row">
      <div class="col-lg-12">
        <div class="card">
          <div class="card-body">

            <form method="post" class="row" enctype="multipart/form-data">
              <button class="btn btn-secondary"><a href="{:url('admin/user/index')}">返回列表</a></button>
              <div class="form-group col-md-12">
                <label for="title">用户邮箱</label>
                <input type="text" class="form-control" id="email" name="email" value="" placeholder="请输入邮箱" />
              </div>
              <div class="form-group col-md-12">
                <label for="seo_keywords">昵称</label>
                <input type="text" class="form-control" id="nickname" name="nickname" value="" placeholder="用户昵称" />
              </div>
              <div class="form-group col-md-12">
                <label for="status">状态</label>
                <div class="clearfix">
                  <div class="custom-control custom-radio custom-control-inline">
                    <input type="radio" id="statusOne" name="sex" class="custom-control-input" value="1">
                    <label class="custom-control-label" for="statusOne">男</label>
                  </div>
                  <div class="custom-control custom-radio custom-control-inline">
                    <input type="radio" id="statusTwo" name="sex" class="custom-control-input" value="2">
                    <label class="custom-control-label" for="statusTwo">女</label>
                  </div>
                  <div class="custom-control custom-radio custom-control-inline">
                    <input type="radio" id="statusZero" name="sex" class="custom-control-input" value="0">
                    <label class="custom-control-label" for="statusZero">保密</label>
                  </div>
                </div>
              </div>
              <div class="form-group col-md-12">
                <label for="seo_keywords">密码</label>
                <input type="password" class="form-control" id="password" name="password" value="" placeholder="密码" />
              </div>
              <div class="form-group col-md-12">
                <label for="seo_keywords">确认密码</label>
                <input type="password" class="form-control" id="repassword" name="repassword" value=""
                  placeholder="确认密码" />
              </div>
              <div class="form-group col-md-12">
                <label for="seo_description">个性签名</label>
                <textarea class="form-control" id="content" name="content" rows="5" value=""
                  placeholder="个性签名"></textarea>
              </div>
              <div class="form-group col-md-12">
                <label>头像上传</label>
                <div class="form-controls">
                  <ul class="list-inline row lyear-uploads-pic mb-0">
                    <li class="col-6 col-md-4 col-lg-2">
                      <figure>
                        <input type="file" name="avatar" id="avatar" hidden>
                        <img id="img"
                          src="{$LoginUser.avatar ? $LoginUser['avatar'] : '/static/home/res/images/upload.png'}">
                      </figure>
                    </li>
                  </ul>
                  <div class="input-group-append"><button class="btn btn-default" type="button"
                      onclick="avatar.click()">上传图片</button></div>
                </div>
              </div>
              <button class="btn btn-primary" id="submit">添 加</button>
            </form>

          </div>
        </div>
      </div>

    </div>

  </div>

</main>
<!--End 页面主要内容-->

<script>
  $('#submit').click(function () {
    console.log(123)
  })

  // 图片预览函数
  function GetObjectURL (file) {
    // createObjectURL  给一个文件对象 可以提取出一个url本地地址出来
    var url = null;

    //判断是否为IE浏览器还是google还是其他浏览器
    if (window.createObjectURL != undefined) {
      url = window.createObjectURL(file)
    } else if (window.URL != undefined) {
      url = window.URL.createObjectURL(file)
    } else if (window.webkitURL != undefined) {
      url = window.webkitURL.createObjectURL(file)
    }
    return url
  }
  $('#avatar').change(function () {
    let file = $(this)[0].files[0] ? $(this)[0].files[0] : {}
    let url = GetObjectURL(file)

    $('#img').attr('src', url)
  })
</script>